package ar.com.angrymachine.hunter.activities;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;

import ar.com.angrymachine.hunter.Activity;
import ar.com.angrymachine.hunter.Game;
import ar.com.angrymachine.hunter.GraphicStyles;
import ar.com.angrymachine.hunter.Locale;

public class DoorActivity extends IncrementalActivity
{
    protected Activity behind;
    protected int level;
    protected Image icon;
    
    public DoorActivity(Activity behind, int level, Image icon)
    {
        this.behind = behind;
        this.level = level;
        this.icon = icon;
    }

    protected int getCompletionTime()
    {
        return level * 300;
    }

    protected int getFinalIncrement(int delta)
    {
        return (int)(delta * Game.current.player.getDisarmPower());
    }

    protected boolean onCompletion()
    {
        return true;
    }

    public String getDescription()
    {
        if(isCompleted())
        {
            return Locale.DOOR;
        }
        else
        {
        	return Locale.percentageLabel(Locale.DOOR, currentTime, getCompletionTime());
        }
    }

    public String getActionText()
    {
        if(isCompleted())
        {
            return Locale.OPENED;
        }
        else
        {
            if(isRunning())
            {
                return Locale.OPENING;
            }
            else
            {
                return Locale.UNLOCK;
            }
        }
    }

    public void paint(Graphics g, Rectangle activityArea)
    {
        GraphicStyles.paintDefaultActivity(g, this, activityArea, icon);
    }

    public void onFinished()
    {
    	Game.current.currentLevel.addActivity(this, behind);
    }
}
